/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dominio;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author igo
 */
@Entity
@Table(name = "OBSERVACAO")
@NamedQueries({
    @NamedQuery(name = "Observacao.findById", query = "SELECT o FROM Observacao o WHERE o.id = :id"),
    @NamedQuery(name = "Observacao.findByIdAluno", query = "SELECT o FROM Observacao o WHERE o.idAluno = :idAluno"),
    @NamedQuery(name = "Observacao.findByDataObs", query = "SELECT o FROM Observacao o WHERE o.dataObs = :dataObs"),
    @NamedQuery(name = "Observacao.findByTexto", query = "SELECT o FROM Observacao o WHERE o.texto = :texto")})
public class Observacao implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Basic(optional=false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name="ID")
    protected Long id;

    @Basic(optional = false)
    @Column(name = "DATA_OBS")
    @Temporal(TemporalType.DATE)
    private Date dataObs;

    @Basic(optional = false)
    @Column(name = "TEXTO")
    private String texto;

    @Basic(optional=false)
    @Column(name="ID_ALUNO")
    private Long idAluno;

    public Observacao(){
    }

    public Observacao(Aluno aluno) {
        this.dataObs = new Date(1L);
        this.idAluno = aluno.getId();
        this.texto = new String();
    }

    public Observacao(Long id) {
        this.id = id;
    }

    public Observacao(Long id, Date dataObs, String texto) {
        this.id = id;
        this.dataObs = dataObs;
        this.texto = texto;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDataObs() {
        return dataObs;
    }

    public void setDataObs(Date dataObs) {
        this.dataObs = dataObs;
    }

    public String getTexto() {
        return texto;
    }

    public void setTexto(String texto) {
        this.texto = texto;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Observacao other = (Observacao) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "dominio.Observacao[id= " + id + "]";
    }

    /**
     * @return the idAluno
     */
    public Long getIdAluno() {
        return idAluno;
    }

    /**
     * @param idAluno the idAluno to set
     */
    public void setIdAluno(Long idAluno) {
        this.idAluno = idAluno;
    }
}
